$(function () {
    // 渲染留言详情
    function getLiuYan() {
        $.ajax({
            method: 'GET',
            url: '/api/comment/list',
            data: {
                valueId: new URLSearchParams(location.search).get('id'),
                typeId: 1,
                page: 1,
                size: 10,
                showType: 0
            },
            success: res => {
                console.log(res);
                $('.comments .h a').attr('href', './commentPost.html?id=' + new URLSearchParams(location.search).get('id'))
                $('.has-comments .load a').attr('href', './topicComment.html?id=' + new URLSearchParams(location.search).get('id'))
                let htmlStr = template('yx_liuyan', res)
                $('#liuyan').html(htmlStr)
            }
        })
    }

    getLiuYan()

    // 专题推荐模块
    function getTuiJian() {
        $.ajax({
            method: 'GET',
            data: {
                page: 1,
                size: 10
            },
            url: '/api/topic/list',
            success: res => {
                // console.log(res);
                let htmlStr = template('yx_tuijian', res)
                $('#tuijian').html(htmlStr)
            }
        })
    }
    getTuiJian()


    function getTopicDetail() {
        $.ajax({
            method: 'GET',
            data: {
                id: new URLSearchParams(location.search).get('id')
            },
            url: '/api/topic/detail',
            success: (res) => {
                // let htmlStr = template('tpl-detail',res.data)
                $('.content').html(res.data.content)
            }
        })
    }
    getTopicDetail()
})